package se.sics.drsm.model;

import java.io.*;
import java.util.Properties;

/**
 * Created with IntelliJ IDEA.
 * User: Shadid Chowdhury
 */
public final class DRSMConfiguration {

    private final String communicationClass;

    public DRSMConfiguration(String communicationClass) {
        super();
        this.communicationClass = communicationClass;
    }

    public String getcommunicationClassName() {
        return communicationClass;
    }

    public void store(String file) throws IOException {
        Properties p = new Properties();
        p.setProperty("communication.component.class", ""
                + communicationClass);
        Writer writer = new FileWriter(file);
        p.store(writer, "se.sics.drsm");
    }

    public static DRSMConfiguration load(String file) throws IOException {
        Properties p = new Properties();
        Reader reader = new FileReader(file);
        p.load(reader);
        String communicationClass = p.getProperty("communication.component.class");

        return new DRSMConfiguration(communicationClass);
    }
}